<template>
    <a-row :gutter="10">
      <a-col :md="leftColMd" :sm="24">
        <a-card :bordered="false">
          <yks-equipment-list ref="equipmentList" @openSubMenu="openSubMenu" @openMainMenu="openMainMenu"/>
        </a-card>
      </a-col>
      <a-col :md="rightColMd" :sm="24">
        <a-card :bordered="false">
          <div style="text-align: right;margin-bottom: -20px;z-index: 1;position:relative">
            <a-tooltip placement="top" title="返回项目列表">
                <a-icon type="close-circle" @click="openMainMenu" />
            </a-tooltip>
          </div>
          <a-tabs defaultActiveKey="2" @change="callback">
            <!-- <a-tab-pane tab="项目维修申请" key="1" forceRender>
               <yks-equipment-devops-list ref="YksEquipmentDevopsList" />             
            </a-tab-pane> -->
            <a-tab-pane tab="项目运维计划" key="2" v-if="hasDailyYksEquipmentDevopsListPermission" forceRender>
              <yks-equipment-devops-service-list v-if="hasDailyYksEquipmentDevopsListPermission" ref="DailyYksEquipmentDevopsList" />        
            </a-tab-pane>
            
            <a-tab-pane tab="项目运维执行" key="3" v-if="hasYksEquipmentDevopsPlanListPermission" forceRender>
              <!-- <yks-equipment-devops-plan-list ref="YksEquipmentDevopsPlanList" />    -->
              <yks-equipment-devops-service-list v-if="hasYksEquipmentDevopsPlanListPermission"  ref="YksEquipmentDevopsPlanList"/>
            </a-tab-pane>
            <a-tab-pane tab="项目运维历史记录" key="4" v-if="hasYksEquipmentDevopsHistoryListPermission" forceRender>
              <!-- <yks-equipment-devops-history-list ref="YksEquipmentDevopsHistoryList" />    -->
              <yks-eqm-devops-service-his-list v-if="hasYksEquipmentDevopsHistoryListPermission" ref="YksEquipmentDevopsHistoryList" />
            </a-tab-pane>
            <a-tab-pane tab="项目物资采购" key="5" v-if="hasMaterialProcurementPermission" forceRender>   
              <yks-material-procurement-list v-if="hasMaterialProcurementPermission" ref="MaterialProcurement" />    
            </a-tab-pane>
            <a-tab-pane tab="项目其他申请" key="6" v-if="hasOtherApplyPermission" forceRender>
              <yks-other-apply-list v-if="hasOtherApplyPermission" ref="OtherApply" />            
            </a-tab-pane>
            <!-- <a-tab-pane tab="运维模板" key="6" forceRender>
              <yks-maintenance-template-list ref="YksMaintenanceTemplateList" />            
            </a-tab-pane> -->
          </a-tabs>
        </a-card>
      </a-col>
    </a-row>
</template>
  <script>
    import DeptBaseInfo from '@/views/system/modules/DeptBaseInfo'
    import DeptUserInfo from '@/views/system/modules/DeptUserInfo'
    import { queryMyDepartTreeList, searchByKeywords } from '@/api/api'
    // import { JeecgListMixin } from '@/mixins/JeecgListMixin'
    import DeptRoleInfo from '@/views/system/modules/DeptRoleInfo'
    import YksEquipmentList from './YksEquipmentList.vue'
    import YksEquipmentManageUsersList from '../mng/YksEquipmentManageUsersList.vue'
    import YksEquipmentConfigurationPlcList from './YksEquipmentConfigurationPlcList'
    import YksEquipmentConfigurationPartList from './YksEquipmentConfigurationPartList.vue'
    import DevEquipmentConfigProductList from './DevEquipmentConfigProductList.vue'
    import YksEquipmentDevopsList from './YksEquipmentDevopsList.vue'
    import YksMaintenanceTemplateList from './YksMaintenanceTemplateList.vue'
    import YksMaterialProcurementList from './YksMaterialProcurementList.vue'
    import YksOtherApplyList from './YksOtherApplyList.vue'
// import YksEquipmentDevopsHistoryList from './YksEquipmentDevopsHistoryList.vue'
    // import YksEquipmentDevopsPlanList from  './YksEquipmentDevopsPlanList.vue'
    import YksEqmDevopsServiceHisList from '../srv/YksEqmDevopsServiceHisList.vue'
    import YksEquipmentDevopsServiceList from '../srv/YksEquipmentDevopsServiceList.vue'
    import { USER_INFO, USER_INFO_PRO,USER_AUTH, SYS_BUTTON_AUTH } from '@/store/mutation-types'
    
    export default {
      name: 'DepartUserList',
      mixins: [],
      components: {
        DeptRoleInfo,
        DeptBaseInfo,
        DeptUserInfo,
        YksEquipmentList,
        YksEquipmentManageUsersList,
        YksEquipmentConfigurationPlcList,
        YksEquipmentConfigurationPartList,
        DevEquipmentConfigProductList,
            YksEquipmentDevopsList,
            YksMaintenanceTemplateList,
            YksMaterialProcurementList,
            YksOtherApplyList,
            // YksEquipmentDevopsHistoryList,
            // YksEquipmentDevopsPlanList,
            YksEqmDevopsServiceHisList,
            YksEquipmentDevopsServiceList
      },
      data() {
        return {
          rightColMd : 0,
          leftColMd : 24,
          currentDeptId: '',
          currentEquipmentId : '',
          model: {},
          checkedKeys: [],
          selectedKeys: [],
          currFlowId : '',
          currFlowName : '',
          labelCol: {
            xs: {span: 24},
            sm: {span: 5}
          },
          wrapperCol: {
            xs: {span: 24},
            sm: {span: 16}
          },
          hasDailyYksEquipmentDevopsListPermission:true,
          hasYksEquipmentDevopsPlanListPermission:true,
          hasYksEquipmentDevopsHistoryListPermission:true,
          hasMaterialProcurementPermission:true,
          hasOtherApplyPermission:true,
        }
      },
      methods: {
        preCheckPermission() {
      this.hasDailyYksEquipmentDevopsListPermission=false
      this.hasYksEquipmentDevopsPlanListPermission=false
      this.hasYksEquipmentDevopsHistoryListPermission=false
      this.hasMaterialProcurementPermission=false
      this.hasOtherApplyPermission=false
      let permissions = sessionStorage.getItem(USER_AUTH)
      if (permissions) {
        permissions = JSON.parse(permissions)
        permissions.forEach((v, k) => 
        {
          if (v.action == 'hasDailyYksEquipmentDevopsListPermission') {
            this.hasDailyYksEquipmentDevopsListPermission = true
          }
          if (v.action == 'hasYksEquipmentDevopsPlanListPermission') {
            this.hasYksEquipmentDevopsPlanListPermission = true
          }
          if (v.action == 'hasYksEquipmentDevopsHistoryListPermission') {
            this.hasYksEquipmentDevopsHistoryListPermission = true
          }
          if (v.action == 'hasMaterialProcurementPermission') {
            this.hasMaterialProcurementPermission = true
          }
          if (v.action == 'hasOtherApplyPermission') {
            this.hasOtherApplyPermission = true
          }
        })
      }
      
    },
        openSubMenu(record){
          this.preCheckPermission()
           this.rightColMd = 24
           this.leftColMd = 0
           this.currentEquipmentId = record.id
           if(this.hasDailyYksEquipmentDevopsListPermission){
            this.$refs.DailyYksEquipmentDevopsList.open(record,'daily')
           }
           if(this.hasMaterialProcurementPermission){
            this.$refs.MaterialProcurement.open(record)
           }
           if(this.hasOtherApplyPermission){
            this.$refs.OtherApply.open(record)
           }
           if(this.hasYksEquipmentDevopsHistoryListPermission){
            this.$refs.YksEquipmentDevopsHistoryList.open(record)
           }
           if(this.hasYksEquipmentDevopsPlanListPermission){
            this.$refs.YksEquipmentDevopsPlanList.open(record)
           }
          //  this.$refs.YksEquipmentDevopsList.open(record,'temporary')
           
            
            
          //  this.$refs.OtherApply.open(record)
           console.log(record)
        },
        openMainMenu() {
           this.rightColMd = 0
           this.leftColMd = 24
        },
        callback(key) {
          console.log(key)
            this.$refs.YksEquipmentDevopsPlanList.serviceTableChange = key

          switch(key){
            case '4':
            this.$refs.YksEquipmentDevopsHistoryList.loadData(1)
              break
          }
          //console.log(key)
        },
        clearSelectedDepartKeys() {
          this.checkedKeys = [];
          this.selectedKeys = [];
          this.currentDeptId = '';
          this.$refs.DeptUserInfo.currentDeptId='';
          this.$refs.DeptRoleInfo.currentDeptId='';
        },
  
      },
      created() {
        this.currFlowId = this.$route.params.id
        this.currFlowName = this.$route.params.name
        // this.loadTree()
      },
    }
  </script>
  <style scoped>
    @import '~@assets/less/common.less'
  </style>